import Vue from 'vue'
import App from "../App"
import Router from 'vue-router'

Vue.use(Router)
// 全加载
// import Index from '../components/Index'
// 懒加载
const Index = () =>
    import ('../components/Index.vue')
const Daily = () =>
    import ('../components/Daily.vue')
const Gifts = () =>
    import ('../components/Gifts.vue')
const Cats = () =>
    import ('../components/Cats.vue')
const DailyDetail = () =>
    import ('../components/DailyDetail.vue')
export default new Router({
    routes: [{
        path: '/',
        component: App,
        children: [{
            path: '',
            component: Index,
            redirect: '/Daily', //设置默认指向的路径
            children: [{
                    path: 'Daily',
                    name: "Daily",
                    component: Daily,
                    meta: {
                        keepAlive: true
                    }
                }, {
                    path: 'Gifts',
                    name: "Gifts",
                    component: Gifts,
                    meta: {
                        keepAlive: true
                    }
                },
                {
                    path: 'Cats',
                    name: "Cats",
                    component: Cats,
                    meta: {
                        keepAlive: true
                    }
                }
            ]
        }, {
            path: '/DailyDetail/:id',
            name: "DailyDetail",
            component: DailyDetail,
            meta: {
                keepAlive: false
            }
        }]
    }]
})
// export default new Router({
//     routes: [{
//         path: '/',
//         component: Index,
//         redirect: '/Daily', //设置默认指向的路径
//         children: [{
//                 path: 'Daily',
//                 name: "Daily",
//                 component: Daily,
//                 meta: {
//                     keepAlive: true
//                 }
//             }, {
//                 path: 'Gifts',
//                 name: "Gifts",
//                 component: Gifts,
//                 meta: {
//                     keepAlive: true
//                 }
//             },
//             {
//                 path: 'Cats',
//                 name: "Cats",
//                 component: Cats,
//                 meta: {
//                     keepAlive: true
//                 }
//             }
//         ]

//     }, {
//         path: '/DailyDetail/:id',
//         name: "DailyDetail",
//         component: DailyDetail,
//         meta: {
//             keepAlive: false
//         }
//     }],
//     // scrollBehavior(to, from, savedPosition) {
//     //     if (savedPosition) {
//     //         return savedPosition
//     //     } else {
//     //         if (from.meta.keepAlive) {
//     //             from.meta.savedPosition = document.body.scrollTop;
//     //         }
//     //         return {
//     //             x: 0,
//     //             y: to.meta.savedPosition || 0
//     //         }
//     //     }
//     // },
// })